//
// Created by sgyt on 2020/1/4.
// 修改文件创建时间，修改文件修时间
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int main(int argc,char *argv[])
{
    int i,fd,res;
    struct timespec times[2];
    struct stat statbuf;

    res = stat("sgyt.txt",&statbuf);
    if(res < 0)
    {
        perror("stat error\n");
    }

    //访问时间
    times[0] = statbuf.st_atim;
    //修改时间
    times[1] = statbuf.st_ctim;
    times[1].tv_nsec = UTIME_NOW;

    fd = open("time.txt",O_RDWR|O_CREAT,0777);
    if(fd < 0)
    {
        perror("open error\n");
    }

    res = futimens(fd,times);
    if(res < 0)
    {
        perror("futimes error\n");
    }

    return 1;
}
